<style>
td.tbW {
	width: 100px;
}
</style>
<script type="text/javascript">
	var i = 0, getModelMapRow = function() {
		return {
			id : '',
			mappedBy : '',
			mappedType : "OneToMany"
		};
	};
	function addModelMap() {
		codeModelMapSetList.datagrid("appendRow", getModelMapRow());
	}
	function removeModelMap() {
		var rows = codeModelMapSetList.datagrid('getChecked');
		printLog(rows);
		if (rows && rows.length > 0) {
			$.messager.confirm('询问', '你确认要删除记录吗?', function(r) {
				if (r) {
					for ( var i = rows.length - 1; i >= 0; i--) {
						printLog(rows[i]);
						var index = codeModelMapSetList.datagrid('getRowIndex',
								rows[i]);
						codeModelMapSetList.datagrid('deleteRow', index);
					}
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
</script>
<div class="easyui-layout" data-options="fit:true">
	<div data-options="region: 'north', border:false">
		<table cellpadding="5">
			<input name="id" type="hidden" value="1" />
			<!-- 	<tr> -->
			<!-- 		<td class="tbW">映射类型:</td> -->
			<!-- 		<td> -->
			<!-- 			<script type="text/javascript">$(function() {$('#76d2c12e-7baf-4d36-a800-a846a65a0b6a').combobox({url:'common.do?loadComboBox&key=MODEL_MAPPED_TYPE&value=',onChange : function(a, b) {$('#76d2c12e-7baf-4d36-a800-a846a65a0b6ahidden').val( $('#76d2c12e-7baf-4d36-a800-a846a65a0b6a').combobox('getValues'));},url:'common.do?loadComboBox&key=MODEL_MAPPED_TYPE&value=',required:false,multiple:false,valueField:'value',textField:'name',disabled:false,editable:false,});});</script><input id="76d2c12e-7baf-4d36-a800-a846a65a0b6a" name="mappedType"  style="width:159px"/><input id="76d2c12e-7baf-4d36-a800-a846a65a0b6ahidden" name="mappedType"  type="hidden" /> -->
			<!-- 		</td> -->
			<!-- 		<td class="tbW">映射表对象:</td> -->
			<!-- 		<td> -->
			<!-- 			<script type="text/javascript">$(function() {$('#0706f3e0-5053-4385-9e3f-50350b3d13fb').combobox({url:'codeCreater.do?loadModelTableCombox&value=',onChange : function(a, b) {$('#0706f3e0-5053-4385-9e3f-50350b3d13fbhidden').val( $('#0706f3e0-5053-4385-9e3f-50350b3d13fb').combobox('getValues'));},url:'codeCreater.do?loadModelTableCombox&value=',required:false,multiple:false,valueField:'value',textField:'name',disabled:false,editable:false,});});</script><input id="0706f3e0-5053-4385-9e3f-50350b3d13fb" name="mappedBy"  style="width:159px"/><input id="0706f3e0-5053-4385-9e3f-50350b3d13fbhidden" name="mappedBy"  type="hidden" /> -->
			<!-- 		</td> -->
			<!-- 	</tr> -->

			<tr>
				<td class="tbW">模块名称(英文):</td>
				<td><input id="moduleName" name="moduleName"
					style="width: 300px;" class="easyui-validatebox textbox"
					data-options="required: true, width: 150" value="trans" /></td>
				<td class="tbW">模型名称(英文):</td>
				<td><input id="modelName" name="modelName"
					style="width: 300px;" class="easyui-validatebox textbox"
					data-options="required: true, width: 150" value="transferScan" />
				</td>
			</tr>
			<tr>

			</tr>
			<tr>
				<td class="tbW">表名:</td>
				<td><input id="tableName" name="tableName"
					style="width: 300px;" class="easyui-validatebox textbox"
					data-options="required: true, width: 150"
					value="TRANS_TRANSFER_SCAN" /></td>
				<td class="tbW">说明:</td>
				<td><input id="comment" name="comment" style="width: 300px;"
					class="easyui-validatebox textbox" data-options="width: 150"
					value="中转扫描" /></td>
			</tr>
		</table>
	</div>
	<div data-options="region:'center',border:false">
		<table id="codeModelMapSetList" data-options="border:false"></table>
		<script type="text/javascript">
			var codeModelMapSetList = null;
			$(function() {
				codeModelMapSetList = $('#codeModelMapSetList');
				codeModelMapSetList.datagrid({
					url : '',
					height : 'auto',
					title : '表映射关系设置',
					striped : 'false',
					fit : true,
					selectOnCheck : false,
					checkOnSelect : false,
					toolbar : '#codeModelMapSetToolbar',
					loadMsg : '数据加载中，请稍等...',
					queryParams : {
						time : new Date().getTime()
					},
					rownumbers : false,
					singleSelect : true,
					idField : 'id',
					autoEditing : true,
					singleEditing : true,
					extEditing : true,
					rowContextMenu : [ {
						text : "编辑",
						iconCls : "icon-edit",
						handler : function(e, index) {
							codeModelMapSetList.datagrid("beginEdit", index);
						}
					} ],
					remoteSort : false,
					enableHeaderClickMenu : true,
					enableHeaderContextMenu : true,
					enableRowContextMenu : false,
					columns : [ [ {
						field : 'id',
						checkbox : true
					}, {
						field : 'mappedBy',
						width : 150,
						title : '映射表',
						sortable : true,
						editor : {
							type : 'text'
						}
					}, {
						field : 'mappedType',
						width : 80,
						title : '映射类型',
						sortable : true,
						formatter : function(value, row, index) {
							var rv = '';
							if ((value + '').indexOf('OneToMany') >= 0) {
								rv += ' 一对多';
							}
							if ((value + '').indexOf('ManyToOne') >= 0) {
								rv += ' 多对一';
							}
							if ((value + '').indexOf('ManyToMany') >= 0) {
								rv += ' 多对多';
							}
							if ((value + '').indexOf('OneToOne') >= 0) {
								rv += ' 一对一';
							}
							return rv;
						},
						editor : {
							type : 'combobox',
							options : {
								valueField : 'mappedType',
								textField : 'name',
								data : [ {
									'mappedType' : 'OneToMany',
									'name' : '一对多'
								}, {
									'mappedType' : 'ManyToOne',
									'name' : '多对一'
								}, {
									'mappedType' : 'ManyToMany',
									'name' : '多对多'
								}, {
									'mappedType' : 'OneToOne',
									'name' : '一对一'
								}, ],
								required : true
							}
						}
					}, ] ],
				});
			});
		</script>
		<div id="codeModelMapSetToolbar">
			<a id="ed5c266f-949f-4ffc-ab5f-c91ba2ef70f9"
				href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-add" plain="true" onclick="addModelMap()">新增</a><a
				id="0c950697-f4fa-448e-8b24-fe321ff7dc36" href="javascript:void(0)"
				class="easyui-linkbutton" iconCls="icon-remove" plain="true"
				onclick="removeModelMap()">删除</a>
		</div>
	</div>
</div>
